<?php
if ($this->uri->segment(4) === "success" && $this->uri->segment(5) === "delete") {
	?>
	<script>
		$(document).ready(function(){
			$("btn_del_record").click(function(){
				//		$(".success-delete").fadeIn(speed, callback)
				$(".success-delete").fadeIn(3000);
				$(".success-delete").hide();
			});
		});
	</script>
	<div class="success-delete" style="background: greenyellow;">You are success for deleting item!!!</div>
	<?php
	//echo '<script>alert("Successful for deleting item!");</script>';
}
if ($department > 0) {
	$page = $this->uri->segment(4);
	$page = $page ? $page : 0;
	echo form_open('department/delete_departments', $page);
	?>
	<table class="table table-striped">
		<thead>
			<tr class="info">
				<th>N&ordm;</th>
				<th><?php echo form_checkbox('checkAll', ''); ?></th>
				<th>Department</th>
				<th>Manager</th>
				<th>Action</th>
			</tr>
		</thead>
		<tbody>
			<?php
			// column id
			$id = 1;
			if ($this->uri->segment(3)) {
				$id = $this->uri->segment(3) + 1;
			} else {
				$id = 1;
			}
			foreach ($department as $data):
				?>
				<tr>
					<td><?php echo $id++; ?></td>
					<td><?php echo form_checkbox(array('id' => 'rcd_check', 'name' => 'rcdCheck[]'), $data->dept_id); ?></td>
					<td><?php echo ucfirst($data->dept_name); ?></td>
					<td><?php echo ucfirst($data->emp_fname) . nbs(2) . strtoupper($data->emp_lname); ?></td>
					<td><?php
		$del = '<i class="icon-remove"></i>';
		$edit = '<i class="icon-edit"></i>';
		echo anchor('department/edit_department/' . $data->dept_id, $edit, 'title="Edit"') . ' | ' . anchor('department/delete_department/' . $this->uri->segment(3) . '/' . $data->dept_id, $del, 'title="Delete" onclick="return confirm(\'Are you sure want to delete?\');"')
				?></td>
				</tr>
				<?php
			endforeach;
			if ($pagination) {
				?>
				<tr>
					<td colspan="4">
						<?php echo form_submit('btn_del_dept', 'Delete', 'onclick="return confirm(\'Are you sure?\');" class="btn btn-primary"') . nbs(3) . anchor('department/add_sub_department', form_button('btn_add_dept', 'Add New', 'class=btn btn-primary"')) ?>
					</td>
					<td>
						<span><?php echo $pagination; ?></span>
					</td>
				</tr>
				<?php
			} else {
				?>
				<tr>
					<td colspan="5">
						<?php echo form_submit('btn_del_dept', 'Delete', 'onclick="return confirm(\'Are you sure?\');" class="btn btn-primary"') . nbs(3) . anchor('department/add_sub_department', form_button('btn_add_dept', 'Add New', 'class="btn btn-primary"')) ?>
					</td>
				</tr>
				<?php
			}
			?>
		</tbody>
	</table>
	<?php
	echo form_close();
} else {
	?>?
	<table>
		<tr>
			<td><?php echo "Data not found!!"; ?></td>
		</tr>
	</table>
<?php } ?>